package com.chen.kotlinproject

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.addTextChangedListener
import androidx.databinding.DataBindingUtil
import androidx.databinding.adapters.TextViewBindingAdapter
import androidx.lifecycle.ViewModelProviders
import com.chen.kotlinproject.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    lateinit var binding: ActivityMainBinding
    lateinit var myViewMOdel: MyViewMOdel
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
        myViewMOdel = ViewModelProviders.of(this).get(MyViewMOdel::class.java)
        binding.model = myViewMOdel
        binding.lifecycleOwner = this
        binding.textView1.addTextChangedListener { it.toString() }
    }
}

